package com.tiger.qcu.controller;

import java.util.List;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.tiger.qcu.domain.TeacherInfo;
import com.tiger.qcu.service.ITeacherInfoService;
import com.tiger.common.utils.poi.ExcelUtil;
import com.tiger.common.core.page.TableDataInfo;

import javax.validation.Valid;
import javax.validation.constraints.*;

/**
 * 教师信息Controller
 * 
 * @author wcj
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/teacherInfo/teacherInfo")
@Api(tags = " teacherInfo管理")
public class TeacherInfoController extends BaseController
{
    @Autowired
    private ITeacherInfoService teacherInfoService;

    /**
     * 查询教师信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询教师信息列表",notes = "教师信息列表查询")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "teacherId", value = "序号", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "teacherName", value = "教师姓名", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "teacherDeptName", value = "学院/院系", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "teacherGraduated", value = "毕业院校及国家", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "teacherInterested", value = "教师研究方向", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "teacherEmail", value = "教师邮箱", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "teacherImg", value = "教师照片", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "createBy", value = "创建者", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "createTime", value = "创建时间", dataType = "Date", dataTypeClass = Date.class),
        @ApiImplicitParam(name = "updateBy", value = "更新者", dataType = "String", dataTypeClass = String.class),
        @ApiImplicitParam(name = "updateTime", value = "更新时间", dataType = "Date", dataTypeClass = Date.class),
        @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class),
    })

    public TableDataInfo list(TeacherInfo teacherInfo)
    {
        startPage();
        List<TeacherInfo> list = teacherInfoService.selectTeacherInfoList(teacherInfo);
        return getDataTable(list);
    }

    /**
     * 导出教师信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:export')")
    @Log(title = "教师信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出教师信息列表",notes = "导出教师信息列表")
    public void export(HttpServletResponse response, TeacherInfo teacherInfo)
    {
        List<TeacherInfo> list = teacherInfoService.selectTeacherInfoList(teacherInfo);
        ExcelUtil<TeacherInfo> util = new ExcelUtil<TeacherInfo>(TeacherInfo.class);
        util.exportExcel(response, list, "教师信息数据");
    }

    /**
     * 获取教师信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:query')")
    @GetMapping(value = "/{teacherId}")
    @ApiOperation(value = "获取教师信息详细信息",notes = "获取教师信息详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "$column.javaField", value = "$column.columnComment", dataType = "teacherId", dataTypeClass = Long.class),
    })
    public AjaxResult getInfo(@Valid @NotNull(message = "teacherId不能为空") @PathVariable("teacherId") Long teacherId)
    {
        return success(teacherInfoService.selectTeacherInfoByTeacherId(teacherId));
    }

    /**
     * 新增教师信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:add')")
    @Log(title = "教师信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增教师信息",notes = "新增教师信息")
    @ApiImplicitParams({
                @ApiImplicitParam(name = "teacherId", value = "序号", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "teacherName", value = "教师姓名", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherDeptName", value = "学院/院系", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherGraduated", value = "毕业院校及国家", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherInterested", value = "教师研究方向", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherEmail", value = "教师邮箱", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherImg", value = "教师照片", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "createBy", value = "创建者", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "createTime", value = "创建时间", dataType = "Date", dataTypeClass = Date.class),
                @ApiImplicitParam(name = "updateBy", value = "更新者", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "updateTime", value = "更新时间", dataType = "Date", dataTypeClass = Date.class),
                @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class),
    })
    public AjaxResult add(@Valid @RequestBody TeacherInfo teacherInfo)
    {
        return toAjax(teacherInfoService.insertTeacherInfo(teacherInfo));
    }

    /**
     * 修改教师信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:edit')")
    @Log(title = "教师信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改教师信息",notes = "修改教师信息")
    @ApiImplicitParams({
                @ApiImplicitParam(name = "teacherId", value = "序号", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "teacherName", value = "教师姓名", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherDeptName", value = "学院/院系", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherGraduated", value = "毕业院校及国家", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherInterested", value = "教师研究方向", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherEmail", value = "教师邮箱", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "teacherImg", value = "教师照片", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
                @ApiImplicitParam(name = "createBy", value = "创建者", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "createTime", value = "创建时间", dataType = "Date", dataTypeClass = Date.class),
                @ApiImplicitParam(name = "updateBy", value = "更新者", dataType = "String", dataTypeClass = String.class),
                @ApiImplicitParam(name = "updateTime", value = "更新时间", dataType = "Date", dataTypeClass = Date.class),
                @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class),
    })
    public AjaxResult edit(@Valid @RequestBody TeacherInfo teacherInfo)
    {
        return toAjax(teacherInfoService.updateTeacherInfo(teacherInfo));
    }

    /**
     * 删除教师信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:teacherInfo:remove')")
    @Log(title = "教师信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teacherIds}")
    @ApiOperation(value = "删除教师信息",notes = "删除教师信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherIds", value = "teacherIds", dataType = "teacherIds", dataTypeClass = Long.class),
    })
    public AjaxResult remove(@Valid @NotEmpty(message = "teacherIds字段不能为空") @PathVariable Long[] teacherIds)
    {
        return toAjax(teacherInfoService.deleteTeacherInfoByTeacherIds(teacherIds));
    }
}
